using System;
using System.Data;
using System.Data.SqlClient;

namespace FAS.DataBase
{
    public class DbController
    {
        IDbController m_IDbManager;

        public DbController()
        {
            DbClassFactory objDbClassFactory = new DbClassFactory();
            m_IDbManager = objDbClassFactory.getDbController();
        }
        public DbController(bool bIsPoolingOn)
        {
            DbClassFactory objDbClassFactory = new DbClassFactory();
            m_IDbManager = objDbClassFactory.getDbController(bIsPoolingOn);
        }
        public DbController(string sCnn)
        {
            DbClassFactory objDbClassFactory = new DbClassFactory();
            m_IDbManager = objDbClassFactory.getDbController(sCnn);
        }

        public bool OpenConnection()
        {
            return m_IDbManager.OpenConnection();
        }

        public bool CloseConnection()
        {
            return m_IDbManager.CloseConnection();
        }

        public bool BeginTransaction()
        {
            return m_IDbManager.BeginTransaction();
        }

        public bool CommitTransaction()
        {
            return m_IDbManager.CommitTransaction();
        }

        public bool RollbackTransaction()
        {
            return m_IDbManager.RollbackTransaction();
        }

        public DataSet Select(string strSqlStatement)
        {
            return m_IDbManager.Select(strSqlStatement);
        }

        public DataSet Select(string strSqlStatement, SqlParameter[] objParas)
        {
            return m_IDbManager.Select(strSqlStatement, objParas);
        }

        public int Execute(string strSqlStatement)
        {
            return m_IDbManager.Execute(strSqlStatement);
        }

        public int Execute(string strSqlStatement, SqlParameter[] objParas)
        {
            return m_IDbManager.Execute(strSqlStatement, objParas);
        }

        public DataSet SpSelect(string strSqlStatement, SqlParameter[] objParas)
        {
            return m_IDbManager.SpSelect(strSqlStatement, objParas);
        }

        public DataSet SpSelect(string strSqlStatement)
        {
            return m_IDbManager.SpSelect(strSqlStatement);
        }

        public void SpExecute(string strSpName, SqlParameter[] objParas)
        {
            m_IDbManager.SpExecute(strSpName, objParas);
        }

        public void SpExecute(string strSpName)
        {
            m_IDbManager.SpExecute(strSpName);
        }
    }
}
